package org.akomantoso.core.data;

import java.io.IOException;

import org.akomantoso.core.data.attribute.Core;
import org.akomantoso.core.data.attribute.IdOpt;
import org.akomantoso.core.data.attribute.Show;
import org.akomantoso.core.data.attribute.Src;
import org.akomantoso.core.io.Externalizable;
import org.akomantoso.core.io.Input;
import org.akomantoso.core.io.Output;
import org.akomantoso.core.io.OutputUtil;

/**
 * The complex type srcType defines the empty content model and the list of attributes for manifestation-level
 * references to external resources.
 * 
 * <pre>
 * 	<xsd:complexType name="srcType">
 * 		<xsd:attributeGroup ref="core"/>
 * 		<xsd:attributeGroup ref="idopt"/>
 * 		<xsd:attributeGroup ref="src"/>
 * 		<xsd:attributeGroup ref="show"/>
 * 	</xsd:complexType>
 * </pre>
 * 
 */
public abstract class SrcType implements Core, IdOpt, Show , Src, Externalizable{

	// Mandatory
	private String _src;
	
	// Optional
	private String _alt;
	
	// Mandatory
	private String _showAs;
	
	// Optional
	private String _shortForm;
	
	// Optional
	private String _id;
	
	// Optional
	private String _evolvingId;
	
	/**
	 * @see org.akomantoso.core.data.attribute.Src#getSrc()
	 */
	@Override
	public String getSrc() {
		return _src;
	}

	/**
	 * @see org.akomantoso.core.data.attribute.Src#setSrc(java.lang.String)
	 */
	@Override
	public void setSrc(String src) {
		_src = src;
	}

	/**
	 * @see org.akomantoso.core.data.attribute.Src#getAlt()
	 */
	@Override
	public String getAlt() {
		return _alt;
	}

	/**
	 * @see org.akomantoso.core.data.attribute.Src#setAlt(java.lang.String)
	 */
	@Override
	public void setAlt(String alt) {
		_alt = alt;
	}

	/**
	 * @see org.akomantoso.core.data.attribute.Show#getShowAs()
	 */
	@Override
	public String getShowAs() {
		return _showAs;
	}

	/**
	 * @see org.akomantoso.core.data.attribute.Show#setShowAs(java.lang.String)
	 */
	@Override
	public void setShowAs(String showAs) {
		_showAs = showAs;
	}

	/**
	 * @see org.akomantoso.core.data.attribute.Show#getShortForm()
	 */
	@Override
	public String getShortForm() {
		return _shortForm;
	}

	/**
	 * @see org.akomantoso.core.data.attribute.Show#setShortForm(java.lang.String)
	 */
	@Override
	public void setShortForm(String shortForm) {
		_shortForm = shortForm;
	}

	/**
	 * @see org.akomantoso.core.data.attribute.IdOpt#getId()
	 */
	@Override
	public String getId() {
		return _id;
	}

	/**
	 * @see org.akomantoso.core.data.attribute.IdOpt#setId(java.lang.String)
	 */
	@Override
	public void setId(String id) {
		_id = id;
	}

	/**
	 * @see org.akomantoso.core.data.attribute.IdOpt#getEvolvingId()
	 */
	@Override
	public String getEvolvingId() {
		return _evolvingId;
	}

	/**
	 * @see org.akomantoso.core.data.attribute.IdOpt#setEvolvingId(java.lang.String)
	 */
	@Override
	public void setEvolvingId(String evolvingId) {
		_evolvingId = evolvingId;
	}

	/**
	 * @see org.akomantoso.core.io.Externalizable#writeExternal(org.akomantoso.core.io.Output)
	 */
	@Override
	public <T extends Output> void writeExternal(T out) throws IOException {
		OutputUtil.writeIdOpt(out, this);
		OutputUtil.writeSrc(out, this);
		OutputUtil.writeShow(out, this);
	}

	/**
	 * @see org.akomantoso.core.io.Externalizable#readExternal(org.akomantoso.core.io.Input)
	 */
	@Override
	public <T extends Input> void readExternal(T in) throws IOException {
		_src = in.readAttribute(Src.ATTRIBUTE_SRC);
		_alt = in.readAttribute(Src.ATTRIBUTE_ALT);
		_showAs = in.readAttribute(Show.ATTRIBUTE_SHOW_AS);
		_shortForm = in.readAttribute(Show.ATTRIBUTE_SHORT_FORM);
		_id = in.readAttribute(IdOpt.ATTRIBUTE_ID);
		_evolvingId = in.readAttribute(IdOpt.ATTRIBUTE_EVOLVING_ID);
	}

	
}
